import 'package:flutter/material.dart';

class BottomActionBar extends StatelessWidget {
  final bool isLiked;
  final bool isCollected;
  final VoidCallback onLikePressed;
  final VoidCallback onCollectPressed;
  final VoidCallback onCategoryPressed;
  final VoidCallback? onSpeakPressed; // 添加语音播放回调

  const BottomActionBar({
    super.key,
    this.isLiked = false,
    this.isCollected = false,
    required this.onLikePressed,
    required this.onCollectPressed,
    required this.onCategoryPressed,
    this.onSpeakPressed,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.only(
        bottom: 16.0, // 减少底部间距
        top: 0.0,
        left: 16.0,
        right: 16.0,
      ),
      child: SafeArea(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            _buildActionButton(
              icon: isLiked ? Icons.favorite : Icons.favorite_border,
              iconColor: isLiked ? Colors.red : Colors.black54,
              onPressed: onLikePressed,
            ),
            _buildActionButton(
              icon: isCollected ? Icons.star : Icons.star_border,
              iconColor: isCollected ? Colors.orange : Colors.black54,
              onPressed: onCollectPressed,
            ),
            _buildActionButton(
              icon: Icons.volume_up, // 语音播放图标
              iconColor: Colors.black54, // 修改颜色以与其他按钮保持一致
              onPressed: onSpeakPressed ?? () {}, // 如果没有提供回调，则使用空函数
            ),
            _buildActionButton(
              icon: Icons.category_outlined,
              iconColor: Colors.black54,
              onPressed: onCategoryPressed,
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildActionButton({
    required IconData icon,
    required Color iconColor,
    required VoidCallback onPressed,
  }) {
    return GestureDetector(
      onTap: onPressed,
      child: Container(
        padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 8.0),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Icon(
              icon,
              color: iconColor,
              size: 30, // 调整图标尺寸
            ),
          ],
        ),
      ),
    );
  }
}